﻿using Microsoft.EntityFrameworkCore;
using G = Gym.Domain.GymAggregate;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Gym.Infrastructure.Persistence.Converters;

namespace Gym.Infrastructure.Persistence.Configurations
{
    public class GymConfigurations : IEntityTypeConfiguration<G.Gym>
    {
        public void Configure(EntityTypeBuilder<G.Gym> builder)
        {
            builder.HasKey(g => g.Id);

            builder.Property(g => g.Id)
                .ValueGeneratedNever();

            builder.Property("_maxRooms")
                .HasColumnName("MaxRooms");

            builder.Property<List<Guid>>("_roomIds")
                .HasColumnName("RoomIds")
                .HasListOfIdsConverter();

            builder.Property<List<Guid>>("_trainerIds")
                .HasColumnName("TrainerIds")
                .HasListOfIdsConverter();

            builder.Property(g => g.Name);

            builder.Property(g => g.SubscriptionId);
        }
    }
}
